<extend name="Public/base" />

<block name="body">
<h3><if condition="ACTION_NAME eq 'add'">新增<else/>編輯</if>模型</h3>

<!-- 標簽頁導航 -->
<div class="panel-body panel panel-default">
        <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" class="active"><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">基 礎</a></li>
                <li role="presentation"><a href="#tab2" aria-controls="profile" role="tab" data-toggle="tab">設 計</a></li>
                <li role="presentation"><a href="#tab3" aria-controls="profile" role="tab" data-toggle="tab">高 級</a></li>
        </ul>
        <div class="panel-body panel panel-default">
                <!-- 表單 -->
                <form action="{:U('update')}" method="post">
                    <div class="tab-content">

                        <!-- 基礎 -->
                        <div role="tabpanel" class="tab-pane active" id="tab1" >
                                <div class="form-group">
                                        <label class="control-label">模型標識<span class="check-tips">（請輸入文檔模型標識）</span></label>
                                        <div class="controls">
                                                <input type="text" class="form-control text input-large" name="name" value="{$info.name}">
                                        </div>
                                </div>
                                <div class="form-group">
                                        <label class="control-label">模型名稱<span class="check-tips">（請輸入模型的名稱）</span></label>
                                        <div class="controls">
                                                <input type="text" class="form-control text input-large" name="title" value="{$info.title}">
                                        </div>
                                </div>
                                <div class="form-group">
                                        <label class="control-label">模型類型<span class="check-tips">（目前支持獨立模型和文檔模型）</span></label>
                                        <div class="controls">
                                                <select name="extend" class="form-control input-s-sm">
                                                        <option value="0">獨立模型</option>
                                                        <option value="1">文檔模型</option>
                                                </select>
                                        </div>
                                </div>
                        </div>

                        <!-- 設計 -->
                        <div role="tabpanel" class="tab-pane" id="tab2" >
                            <div class="row">
                                     <div class="col-sm-6">  
                                         <li href="#" class="list-group-item disabled">						<label class="item-label">字段管理<span class="check-tips">（只有新增了字段，該表才會真正建立）</span></label>
                                <span>字段列表 		[ <a href="{:U('Attribute/add?model_id='.$info['id'])}" target="_balnk">新增</a>
                                                <a href="{:U('Attribute/index?model_id='.$info['id'])}" target="_balnk">管理</a> ] </span></li>	
                                        <div class="list-group">
                                                        <foreach name="fields" item="field" key="k">

                                 <span href="#" class="list-group-item">{$field['title']} [{$field['name']}]</span>

                                                        </foreach>
                                        </div>

                                <div class="form-group">
                                        <label class="item-label">表單顯示分組<span class="check-tips">（用於表單顯示的分組，以及設置該模型表單排序的顯示）</span></label>
                                        <div class="controls">
                                                <input type="text" class="form-control input-large" name="field_group" value="{$info.field_group}">
                                        </div>
                                </div>
       </div>
                            </div>

        <div class="row">
                                 <volist name=":parse_field_attr($info['field_group'])" id="vo">
                                     <div class="col-sm-6">
                                <div class="list-group">
                                <a href="#" class="list-group-item disabled">
                                   {$vo}
                                </a>
                                        <ul class="dragsort needdragsort" data-group="{$key}">    
                                <foreach name="fields" item="field" key="k">
                                 <if condition="(($field['group'] eq $key) or($i eq 1 and !isset($field['group']))) and ($field['is_show'] eq 1)">   
                                     <li class="getSort">
                                <a href="#" class="list-group-item">
                                  <span data="{$field['id']}">{$field['title']} [{$field['name']}]</span>
                                <input type="hidden" name="field_sort[{$key}][]" value="{$field['id']}"/>
                                </a>
                                         </li>
                                </if>
                                </foreach>
                                        </ul>     
                                </div>
                                     </div>
                                </volist>     
        </div>




                                <div class="form-group" style="clear:both; padding-top: 10px;">
                                        <label class="control-label">列表定義<span class="check-tips">（默認列表模板的展示規則）</span></label>
                                        <textarea name="list_grid" class="form-control">{$info.list_grid}</textarea>
                                </div>

                                <div class="form-group">
                                        <label class="control-label">默認搜索字段<span class="check-tips">（默認列表模板的默認搜索項）</span></label>
                                        <div class="controls">
                                                <input type="text" class="form-control text input-large" name="search_key" value="{$info.search_key}">
                                        </div>
                                </div>
                                <div class="form-group">
                                        <label class="control-label">高級搜索字段<span class="check-tips">（默認列表模板的高級搜索項）</span></label>
                                        <div class="controls">
                                                <input type="text" class="form-control text input-large" name="search_list" value="{$info.search_list}">
                                        </div>
                                </div>
                        </div>

                        <!-- 高級 -->
                        <div role="tabpanel" class="tab-pane" id="tab3" >
                                <div class="form-group">
                                        <label class="control-label">列表模板<span class="check-tips">（自定義的列表模板，放在Application\Admin\View\Think下，不寫則使用默認模板）</span></label>
                                        <div class="controls">
                                                <input type="text" class="form-control text input-large" name="template_list" value="{$info.template_list}">
                                        </div>
                                </div>
                                <div class="form-group">
                                        <label class="control-label">新增模板<span class="check-tips">（自定義的新增模板，放在Application\Admin\View\Think下，不寫則使用默認模板）</span></label>
                                        <div class="controls">
                                                <input type="text" class="form-control text input-large" name="template_add" value="{$info.template_add}">
                                        </div>
                                </div>
                                <div class="form-group">
                                        <label class="control-label">編輯模板<span class="check-tips">（自定義的編輯模板，放在Application\Admin\View\Think下，不寫則使用默認模板）</span></label>
                                        <div class="controls">
                                                <input type="text" class="form-control text input-large" name="template_edit" value="{$info.template_edit}">
                                        </div>
                                </div>
                                <div class="form-group">
                                        <label class="control-label">列表數據大小<span class="check-tips">（默認列表模板的分頁屬性）</span></label>
                                        <div class="controls">
                                                <input type="text" class="form-control text input-small" name="list_row" value="{$info.list_row}">
                                        </div>
                                </div>
                        </div>

                        <!-- 按鈕 -->
                        <div class="form-item cf">
                                <label class="item-label"></label>
                                <div class="controls edit_sort_btn">
                                        <input type="hidden" name="id" value="{$info['id']}"/>
                                        <button  type="submit" class="btn btn-primary ladda-button" data-style="slide-up">確 定</button>
                                        <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
                                </div>
                        </div>
                </form>
        </div>
</div>
</block>
<block name="script">
<script src="__STATIC__/jquery-1.10.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/jquery.dragsort-0.5.2.min.js"></script>
<script type="text/javascript" charset="utf-8">
Think.setValue("extend", {$info.extend|default=0});

//拖曳插件初始化
$(function(){
$(".needdragsort").dragsort({
     dragSelector:'li',
     placeHolderTemplate: '<li class="draging-place">&nbsp;</li>',
     dragBetween:true,	//允許拖動到任意地方
     dragEnd:function(){
         var self = $(this);
         self.find('input').attr('name', 'field_sort[' + self.closest('ul').data('group') + '][]');
     }
 });
})
</script>
</block>

